The present invention relates to methods and system for memory management in general, and to methods and systems for managing memory in pages, in particular.
Intermediate storage elements are known in the art. A conventional computer system includes random access memory (RAM), which is used for uploading software objects, executing them and for storing data objects, used by the software objects.
The RAM size is often limited. When the memory requirements exceed the RAM size, then the system can allocate a storage area on another storage element, such as a hard drive, and define this storage area as virtual memory, serving as an extension of the RAM. Data portions, which are not often used, can be stored in the virtual memory until the system retrieves them for further processing.
The RAM of a conventional computer system can be in the range of 32MB-2GB and the numbers increase constantly. It will be appreciated by those skilled in the art that the small data segments (a single bit, a byte and a word) can not be used for allocating memory in an efficient way. Conventional methods for managing memory allocate large portions of these segments. These portions are in the range of several kilobytes to several megabytes.
One conventional method, known in the art, for managing memory resources is called paged memory. This method determines a plurality of memory portions, called memory pages. Each memory page is of a predetermined set of sizes (for example, 4 KB, 16 KB). The memory is managed by a memory management module within the computer system, which can be implemented either in hardware or in software, either as a part of the operating system or of the computer chip-set.
The memory management module receives a memory allocation request for a block of memory, from a software module. The memory management module allocates memory pages having a total size, which can contain the requested amount of memory.
For each allocated memory portion, the memory allocator provides both a physical location and a logical representation. The physical location includes a selected portion of the overall memory size available in the computer system. The logical representation is the address seen by the software module. This address is used to index an entry in a specialtable, called page table, which points to the physical location. It is noted that additional management mechanisms can be added to this structure, but those mechanisms will not be discussed herein below, so as to maintain the simplicity of the description.
The entries in the page table are called page table entries. Page table entries should indicate the physical address of the page, the page size and additional attributes about the page. The page size is always a power of 2, and the page address is always aligned on a page boundary (that is, can be divided by the page size). A page record is adapted to the environment in which it is processed. In a sixty-four-bit processor, this record includes sixty-four bits and so does the entire address space. In an example, where the size of a memory page block is 4 KB (212), fifty-two bits are required to point to any such block. In a system, which utilizes memory pages in several sizes, the page record has to include additional information relating to the size of the page associated with that record. The remaining bits in the record are used for various attributes such as, xe2x80x9cread onlyxe2x80x9d, xe2x80x9cmodifiedxe2x80x9d, xe2x80x9cwrite oncexe2x80x9d, xe2x80x9cfor system use onlyxe2x80x9d and the like.
Reference is now made to FIGS. 1A and 1B. FIG. 1A is a representation of a page table entry string, generally referenced 10, representing a predetermined page, which is known in the art. FIG. 1B is a representation of the memory page record string of FIG. 1A, representing a different memory page.
With reference to FIG. 1A, string 10 is divided into sub strings 12, 14 and 16. Sub-string 12 is a representation of the page address, sub-string 14 is a representation of the page size and sub-string 16 is a representation of the memory page attributes.
In the present example, the overall length of string 10 is sixty four bits, the length of page address sub-string 12 is fifty two bits, and the page size representation sub-string 14 includes three bits, which provide up to eight options of page sizes (23). In the present example, the system utilizes the following page sizes: 4 KB, 8 KB, 16 KB, 32 KB, 64 KB, 128 KB, 256 KB and 512 KB. As a result of the above, the length which is set for the attribute sub-string is nine bits. It is noted that the system can utilize page sizes, which are not sequential, such as 4 KB, 32 KB, 64 KB, 256 KB, and the like.
Page size representation sub-string 14 stores a sequence xe2x80x9c000xe2x80x9d which, in the present example, indicates the first and smallest page size of 4 KB. With reference to FIG. 1B, the page size representation sub-string 14 stores a sequence xe2x80x9c010xe2x80x9d which, in the present example, indicates the third page size of 16 KB.
According to the above arrangement, the length of the attribute representation sub-string is the result of subtraction of the address sub-string and the size sub-string from the overall length of the page record string.
The above arrangement is also limited to eight different sizes of pages. If the system utilizes a greater number of pages, then additional bits have to be allocated from the attribute sub-string to the page size sub-string, thus reducing even more the length of the attribute sub-string.